package com.wnn.demo.advice;


import com.wnn.demo.pojo.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

//该异常是自定义异常，抛出的异常都是
// 形式1、 throw  new MyException(ResultCode.error);
// 形式2、 throw MyException.error();   抛出静态方法

@Getter
@NoArgsConstructor
public class MyException extends RuntimeException{

//    自定义异常继承Exception,拥有一个属性，该属性是一个Result包装类
    private ResultCode resultCode;
    private String  msg;

//  适用于构造定义好的 sucess,code,msg           msg在ResultCode已经定义好
    public MyException(ResultCode resultCode){
        this.resultCode = resultCode;
        this.msg = resultCode.getMsg();
    }

    //  适用于构造定义好的 sucess,code           msg可以从throw自己手写
    public MyException(ResultCode resultCode,String msg){
        this.resultCode = resultCode;
        this.msg = msg;
    }


}
